package com.stenio.fancat.controller;

import org.springframework.util.StreamUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

@RestController
public class ContentController {

    @RequestMapping("proxy")
    public void proxy(HttpServletResponse response) {
        String s = "https://fancat.oss-cn-beijing.aliyuncs.com/e3471787e5204582a186dae1bd06f409.html";
        try {
            InputStream in = new URL(s).openStream();
            ServletOutputStream out = response.getOutputStream();
            StreamUtils.copy(in, out);
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
